//
//  SISSBuyerDemandInfoView.m
//  SISSAPP
//
//  Created by 优房网 on 2017/7/20.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSBuyerDemandInfoView.h"


@interface SISSBuyerDemandInfoView ()

/// 意向区域Label
@property (weak, nonatomic) UILabel *intentionRegionLabel;
@property (weak, nonatomic) UILabel *intentionRegionTitleLabel;
/// 意向小区Label
@property (weak, nonatomic) UILabel *intentionNeighborLabel;
@property (weak, nonatomic) UILabel *intentionNeighborTitleLabel;
/// 预算Label
@property (weak, nonatomic) UILabel *budgetLabel;
@property (weak, nonatomic) UILabel *budgetTitleLabel;
/// 户型Label
@property (weak, nonatomic) UILabel *houseTypeLabel;
@property (weak, nonatomic) UILabel *houseTypeTitleLabel;
/// 面积Label
@property (weak, nonatomic) UILabel *areaLabel;
@property (weak, nonatomic) UILabel *areaTitleLabel;
/// 意向楼层Label
@property (weak, nonatomic) UILabel *floorLabel;
@property (weak, nonatomic) UILabel *floorTitleLabel;
/// 朝向Label
@property (weak, nonatomic) UILabel *directionLabel;
@property (weak, nonatomic) UILabel *directionTitleLabel;
/// 装修程度Label
@property (weak, nonatomic) UILabel *decorationLabel;
@property (weak, nonatomic) UILabel *decorationTitleLabel;
/// 购房目的Label
@property (weak, nonatomic) UILabel *purposeLabel;
@property (weak, nonatomic) UILabel *purposeTitleLabel;
/// 其它需求说明Label
@property (weak, nonatomic) UILabel *otherDemandDescLabel;
@property (weak, nonatomic) UILabel *otherDemandDescTitleLabel;
/// 合作说明Label
@property (weak, nonatomic) UILabel *cooperationDescLabel;
@property (weak, nonatomic) UILabel *cooperationDescTitleLabel;

@property (weak, nonatomic) UILabel *bottomLabel;

@end
@implementation SISSBuyerDemandInfoView

- (void)setPassengerCoopDetailModel:(SISSPassengerCooperationDetailModel *)passengerCoopDetailModel {
    _passengerCoopDetailModel = passengerCoopDetailModel;
    
    self.intentionRegionLabel.text = [NSString stringWithFormat:@"%@-%@",passengerCoopDetailModel.region,passengerCoopDetailModel.regionDetail];
    self.intentionNeighborLabel.text = passengerCoopDetailModel.neighbourhood;
    self.budgetLabel.text = [NSString stringWithFormat:@"%@-%@万",@(passengerCoopDetailModel.minPrice),@(passengerCoopDetailModel.maxPrice)];
    self.houseTypeLabel.text = passengerCoopDetailModel.houseType;
    self.areaLabel.text = [NSString stringWithFormat:@"%@-%@㎡",@(passengerCoopDetailModel.minArea),@(passengerCoopDetailModel.maxArea)];
    self.floorLabel.text = (passengerCoopDetailModel.minFloor != 0 && passengerCoopDetailModel.maxFloor != 0) ? [NSString stringWithFormat:@"%zd-%zd层",passengerCoopDetailModel.minFloor,passengerCoopDetailModel.maxFloor] : @"";;
    self.directionLabel.text = passengerCoopDetailModel.direction;
    self.decorationLabel.text = passengerCoopDetailModel.decoration;
    self.purposeLabel.text = passengerCoopDetailModel.purpose;
    self.otherDemandDescLabel.text = passengerCoopDetailModel.otherdesc.length > 0 ? passengerCoopDetailModel.otherdesc : @" ";
    self.cooperationDescLabel.text = passengerCoopDetailModel.cooperation_desc.length > 0 ? passengerCoopDetailModel.cooperation_desc : @" ";
}

- (void)setBottomStr:(NSString *)bottomStr {
    _bottomStr = bottomStr;
    self.cooperationDescTitleLabel.hidden = YES;
    WeakSelf
    [self.bottomLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.otherDemandDescTitleLabel);
        make.top.equalTo(weakSelf.otherDemandDescLabel.mas_bottom).offset(8);
        make.bottom.equalTo(weakSelf).offset(-8);
    }];
    self.bottomLabel.text = bottomStr;
}

#pragma mark - UI
- (void)initUI {
    [super initUI];
    self.backgroundColor = COLOR(0xF1F1F5);
    
    UILabel *intentionRegionTitleLabel = [[UILabel alloc] init];
    intentionRegionTitleLabel.text = @"意向区域：";
    intentionRegionTitleLabel.textColor = COLOR(0x8998A5);
    intentionRegionTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:intentionRegionTitleLabel];
    self.intentionRegionTitleLabel = intentionRegionTitleLabel;
    
    UILabel *intentionRegionLabel = [[UILabel alloc] init];
    intentionRegionLabel.text = @"意向区域";
    intentionRegionLabel.textAlignment = NSTextAlignmentLeft;
    intentionRegionLabel.textColor = MAIN_TEXT_COLOR;
    intentionRegionLabel.font = [UIFont boldSystemFontOfSize:15];
    intentionRegionLabel.numberOfLines = 0;
    [self addSubview:intentionRegionLabel];
    self.intentionRegionLabel = intentionRegionLabel;
    
    UILabel *intentionNeighborTitleLabel = [[UILabel alloc] init];
    intentionNeighborTitleLabel.text = @"意向小区：";
    intentionNeighborTitleLabel.textColor = COLOR(0x8998A5);
    intentionNeighborTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:intentionNeighborTitleLabel];
    self.intentionNeighborTitleLabel = intentionNeighborTitleLabel;
    
    UILabel *intentionNeighborLabel = [[UILabel alloc] init];
    intentionNeighborLabel.text = @"dream";
    intentionNeighborLabel.textColor = MAIN_TEXT_COLOR;
    intentionNeighborLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:intentionNeighborLabel];
    self.intentionNeighborLabel = intentionNeighborLabel;
    
    UILabel *budgetTitleLabel = [[UILabel alloc] init];
    budgetTitleLabel.text = @"预算：";
    budgetTitleLabel.textColor = COLOR(0x8998A5);
    budgetTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:budgetTitleLabel];
    self.budgetTitleLabel = budgetTitleLabel;
    
    UILabel *budgetLabel = [[UILabel alloc] init];
    budgetLabel.text = @"预算";
    budgetLabel.textColor = MAIN_TEXT_COLOR;
    budgetLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:budgetLabel];
    self.budgetLabel = budgetLabel;
    
    UILabel *houseTypeTitleLabel = [[UILabel alloc] init];
    houseTypeTitleLabel.text = @"户型：";
    houseTypeTitleLabel.textColor = COLOR(0x8998A5);
    houseTypeTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:houseTypeTitleLabel];
    self.houseTypeTitleLabel = houseTypeTitleLabel;
    
    UILabel *houseTypeLabel = [[UILabel alloc] init];
    houseTypeLabel.text = @"5房";
    houseTypeLabel.textColor = MAIN_TEXT_COLOR;
    houseTypeLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:houseTypeLabel];
    self.houseTypeLabel = houseTypeLabel;
    
    UILabel *areaTitleLabel = [[UILabel alloc] init];
    areaTitleLabel.text = @"面积：";
    areaTitleLabel.textColor = COLOR(0x8998A5);
    areaTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:areaTitleLabel];
    self.areaTitleLabel = areaTitleLabel;
    
    UILabel *areaLabel = [[UILabel alloc] init];
    areaLabel.text = @"200㎡";
    areaLabel.textColor = MAIN_TEXT_COLOR;
    areaLabel.font = [UIFont boldSystemFontOfSize:15];
    areaLabel.numberOfLines = 0;
    [self addSubview:areaLabel];
    self.areaLabel = areaLabel;
    
    UILabel *floorTitleLabel = [[UILabel alloc] init];
    floorTitleLabel.text = @"意向楼层：";
    floorTitleLabel.textColor = COLOR(0x8998A5);
    floorTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:floorTitleLabel];
    self.floorTitleLabel = floorTitleLabel;
    
    UILabel *floorLabel = [[UILabel alloc] init];
    floorLabel.text = @"10-20层";
    floorLabel.textColor = MAIN_TEXT_COLOR;
    floorLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:floorLabel];
    self.floorLabel = floorLabel;
    
    UILabel *directionTitleLabel = [[UILabel alloc] init];
    directionTitleLabel.text = @"朝向：";
    directionTitleLabel.textColor = COLOR(0x8998A5);
    directionTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:directionTitleLabel];
    self.directionTitleLabel = directionTitleLabel;
    
    UILabel *directionLabel = [[UILabel alloc] init];
    directionLabel.text = @"朝东";
    directionLabel.textColor = MAIN_TEXT_COLOR;
    directionLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:directionLabel];
    self.directionLabel = directionLabel;
    
    UILabel *purposeTitleLabel = [[UILabel alloc] init];
    purposeTitleLabel.text = @"购房目的：";
    purposeTitleLabel.textColor = COLOR(0x8998A5);
    purposeTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:purposeTitleLabel];
    self.purposeTitleLabel = purposeTitleLabel;
    
    UILabel *purposeLabel = [[UILabel alloc] init];
    purposeLabel.text = @"购房目的";
    purposeLabel.textColor = MAIN_TEXT_COLOR;
    purposeLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:purposeLabel];
    self.purposeLabel = purposeLabel;
    
    UILabel *decorationTitleLabel = [[UILabel alloc] init];
    decorationTitleLabel.text = @"装修程度：";
    decorationTitleLabel.textColor = COLOR(0x8998A5);
    decorationTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:decorationTitleLabel];
    self.decorationTitleLabel = decorationTitleLabel;
    
    UILabel *decorationLabel = [[UILabel alloc] init];
    decorationLabel.text = @"精装";
    decorationLabel.textColor = MAIN_TEXT_COLOR;
    decorationLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:decorationLabel];
    self.decorationLabel = decorationLabel;
    
    UILabel *otherDemandDescTitleLabel = [[UILabel alloc] init];
    otherDemandDescTitleLabel.text = @"其它需求说明：";
    otherDemandDescTitleLabel.textColor = COLOR(0x8998A5);
    otherDemandDescTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:otherDemandDescTitleLabel];
    self.otherDemandDescTitleLabel = otherDemandDescTitleLabel;
    
    UILabel *otherDemandDescLabel = [[UILabel alloc] init];
    otherDemandDescLabel.text = @"顺分顺水，环境优美";
    otherDemandDescLabel.textColor = MAIN_TEXT_COLOR;
    otherDemandDescLabel.font = [UIFont boldSystemFontOfSize:15];
    otherDemandDescLabel.textAlignment = NSTextAlignmentLeft;
    otherDemandDescLabel.numberOfLines = 0;
    [self addSubview:otherDemandDescLabel];
    self.otherDemandDescLabel = otherDemandDescLabel;
    
    UILabel *cooperationDescTitleLabel = [[UILabel alloc] init];
    cooperationDescTitleLabel.text = @"合作说明：";
    cooperationDescTitleLabel.textColor = COLOR(0x8998A5);
    cooperationDescTitleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:cooperationDescTitleLabel];
    self.cooperationDescTitleLabel = cooperationDescTitleLabel;
    
    UILabel *cooperationDescLabel = [[UILabel alloc] init];
    cooperationDescLabel.text = @"合作愉快";
    cooperationDescLabel.textColor = MAIN_TEXT_COLOR;
    cooperationDescLabel.font = [UIFont boldSystemFontOfSize:15];
    cooperationDescLabel.numberOfLines = 0;
    [self addSubview:cooperationDescLabel];
    self.cooperationDescLabel = cooperationDescLabel;
    
    UILabel *bottomLabel = [[UILabel alloc] init];
    bottomLabel.textColor = COLOR(0x8998A5);
    bottomLabel.text = self.bottomStr;
    bottomLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:bottomLabel];
    self.bottomLabel = bottomLabel;
}

#pragma mark - 布局
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.intentionRegionTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf).offset(margin);
        make.top.equalTo(weakSelf).offset(3 * margin);
    }];
    [self.intentionRegionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.intentionRegionTitleLabel.mas_right);
        make.top.equalTo(weakSelf.intentionRegionTitleLabel);
//        make.right.equalTo(weakSelf).offset(-margin).priority(900);
    }];
    
    [self.intentionNeighborTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.intentionRegionTitleLabel);
        make.top.equalTo(weakSelf.intentionRegionLabel.mas_bottom).offset(2 * margin);
    }];
    [self.intentionNeighborLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.intentionNeighborTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.intentionNeighborTitleLabel);
    }];
    
    [self.budgetTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.intentionNeighborTitleLabel);
        make.top.equalTo(weakSelf.intentionNeighborTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.budgetLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.budgetTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.budgetTitleLabel);
    }];
    
    [self.houseTypeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.budgetTitleLabel);
        make.top.equalTo(weakSelf.budgetTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.houseTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseTypeTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.houseTypeTitleLabel);
    }];
    
    [self.areaTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.houseTypeTitleLabel);
        make.top.equalTo(weakSelf.houseTypeTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.areaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.areaTitleLabel.mas_right);
        make.top.equalTo(weakSelf.areaTitleLabel);
    }];
    
    [self.floorTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.areaTitleLabel);
        make.top.equalTo(weakSelf.areaLabel.mas_bottom).offset(2 * margin);
    }];
    [self.floorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.floorTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.floorTitleLabel);
    }];
    
    [self.directionTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.floorTitleLabel);
        make.top.equalTo(weakSelf.floorTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.directionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.directionTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.directionTitleLabel);
    }];
    
    [self.purposeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.directionTitleLabel);
        make.top.equalTo(weakSelf.directionTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.purposeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.purposeTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.purposeTitleLabel);
    }];
    
    [self.decorationTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.purposeTitleLabel);
        make.top.equalTo(weakSelf.purposeTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.decorationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.decorationTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.decorationTitleLabel);
    }];
    
    [self.otherDemandDescTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.decorationTitleLabel);
        make.top.equalTo(weakSelf.decorationTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.otherDemandDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.otherDemandDescTitleLabel.mas_right);
        make.top.equalTo(weakSelf.otherDemandDescTitleLabel);
        make.right.equalTo(weakSelf).offset(-margin);
    }];
    
    [self.cooperationDescTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.otherDemandDescTitleLabel);
        make.top.equalTo(weakSelf.otherDemandDescLabel.mas_bottom).offset(2 * margin);
    }];
    [self.cooperationDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.cooperationDescTitleLabel.mas_right);
        make.top.equalTo(weakSelf.cooperationDescTitleLabel);
        make.right.equalTo(weakSelf).offset(-margin);
    }];
    [self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.cooperationDescTitleLabel);
        make.top.equalTo(weakSelf.cooperationDescLabel.mas_bottom).offset(margin);
        make.bottom.equalTo(weakSelf).offset(-margin);
    }];

}


@end
